package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// 订单模块
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    //订单提交  //二级地址
    @PostMapping("/submit")
    public ResultInfo submit(@RequestBody Order order){
        //调用
        orderService.submit(order);
        //返回
        return ResultInfo.success();
    }

    //历史订单 //二级地址
    @GetMapping("/userPage")
    public ResultInfo findUserPage(@RequestParam(name = "page",defaultValue = "1") Integer pageNum,
                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        //调用
        Page<Order> page = orderService.findUserPage(pageNum, pageSize);
        //返回
        return ResultInfo.success(page);
    }
}
